package com.ajk.server.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import com.ajk.server.dao.provider.ReportProvider;
import com.ajk.server.model.Report;
import com.ajk.server.model.ReportItem;

public interface ReportMapper {
	
	
	@Insert("insert into t_report(report_no,report_type,user_id,doctor_id,user_rela_name,user_sex,user_name,check_item,"
			+ "health_advice,doctor_advice,device_id) "
			+ "value (#{reportNo},#{reportType},#{userId},#{doctorId},#{userRealName},#{userSex},#{userName},#{checkItem},"
			+ "#{healthAdvice},#{doctorAdvice},#{deviceId})")
	@Options(useGeneratedKeys=true)
	public Integer insertReport(Report report);
	
	@Insert("insert into t_report_item(report_id,part_id,part_path,influence_level,time_duration,disease_number,disease_grade) "
			+ " value (#{reportId},#{partId},#{partPath},#{influenceLevel},#{timeDuration},#{diseaseNumber},#{diseaseGrade})")
	public Integer insertReportItem(ReportItem reportItem);
	
	@SelectProvider(type=ReportProvider.class,method="getReportList")
	public List<Report> getReportList(Report report);
	
	@Select("select * from t_report where id = #{id}")
	public Report getReportById(Integer id);
	
	@Select("select a.*,b.name part_name from t_report_item a,t_report_part b where a.part_id = b.id and a.report_id = #{reportId}")
	public List<ReportItem> getReportItemByReportId(Integer reportId);

}